#include<bits/stdc++.h>
using namespace std;
double a[1000010];
int main(){
	int n , p = 1 , m;
	cin >> n;
	cin >> m;
	int k = n;
	while(k > 0){
		a[p] = k % m;
		k = (k - a[p]) / m;
		p = p + 1;
	}
	p = p - 1;
	for(int i = p ; i >= 1 ; i--){
		if(a[i] >= 0 && a[i] <= 9){
			cout << a[i];
			continue;
		}
		a[i] = a[i] - 10 + 'A';
		cout << (char)a[i];
	}
	cout << endl;
	return 0;
}
